package com.wanbatv.wanba.ahitv.activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.wanbatv.wanba.ahitv.R;
import com.wanbatv.wanba.ahitv.util.DataReport;
import com.wanbatv.wanba.ahitv.util.Util;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;

import de.hdodenhof.circleimageview.CircleImageView;


public class FittimeSimplePlayerActivity extends Activity implements
        MediaPlayer.OnPreparedListener,MediaPlayer.OnCompletionListener,SurfaceHolder.Callback,MediaPlayer.OnErrorListener{
    private SurfaceView surfaceView;
    MediaPlayer mediaPlay;
    SurfaceHolder surfaceholder;
    ProgressBar playprogressbar;
    private TextView fit_erji_demo_tv1;
    private TextView fit_erji_demo_tv2;
    private static final int MSG_PLAY_PROGRESS = 1;

    private RelativeLayout fit_daka_relayout;

    private ImageView fit_daka_gou1;
    private ImageView fit_daka_gou2;
    private ImageView fit_daka_gou3;

    private ImageView fit_daka_face1;
    private ImageView fit_daka_face2;
    private ImageView fit_daka_face3;

    private ImageView fit_daka_queding;
    int time=0;

    private TextView fit_daka_name;
    private TextView fit_daka_time;
    private TextView fit_daka_col;

    private CircleImageView fit_daka_touxiang;
    private int biaoqing_num=3;
    String userid=null;
    String username=null;
    String userurl=null;
    private int bofang_time=0;

    View bofang_view;
    ImageView playstat;
    ImageView playstop;
    ImageView playback;
    ImageView playgo;

    //标记快进快退按键状态：正常，未进行快进快退操作
    private static final int STATE_FAST_SEEK_IDLE = 0;
    //标记快进快退按键状态：用户长按着按键，但还未开始快进快退
    private static final int STATE_FAST_SEEK_PREPARED = 1;
    //标记快进快退按键状态：已经开始快进快退
    private static final int STATE_FAST_SEEK_START = 2;
    private int mStateFastSeek = STATE_FAST_SEEK_IDLE;
    private KeyEvent mLastEvent = null;
    private long KUAIJIN_TIME=0;
    private KeyEvent mDownEvent = null;
    int mTime=0;
    int endtime=0;
    Handler mHandler = new Handler(Looper.getMainLooper()) {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_PLAY_PROGRESS:
                    try{
                        if (mediaPlay.isPlaying()) {
                            playprogressbar.setProgress(mediaPlay.getCurrentPosition());
                            bofang_time=mediaPlay.getCurrentPosition();
                            int b=bofang_time/1000;
                            int s=b%60;
                            int m=b/60;
                            String ss=null;
                            if(s<10){
                                ss="0"+s;
                            }else{
                                ss=s+"";
                            }
                            fit_erji_demo_tv1.setText(m+":"+ss);
                        }else{

                        }
                    }catch (IllegalStateException e){

                    }

                    mHandler.removeMessages(MSG_PLAY_PROGRESS);
                    mHandler.sendEmptyMessageDelayed(MSG_PLAY_PROGRESS, 1000);
                    break;
                    }



            }
        };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fittime_simple_player);
        surfaceView=(SurfaceView)findViewById(R.id.fit_surfaceview);
        surfaceholder = surfaceView.getHolder();
        playprogressbar = (ProgressBar) findViewById(R.id.fit_play_progressbar);
        fit_erji_demo_tv1=(TextView)findViewById(R.id.fit_erji_demo_tv1);
        fit_erji_demo_tv2=(TextView)findViewById(R.id.fit_erji_demo_tv2);
        surfaceholder.setFixedSize(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        surfaceholder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        surfaceholder.addCallback(this);

        fit_daka_relayout=(RelativeLayout)findViewById(R.id.fit_daka_relayout);
        fit_daka_gou1=(ImageView)findViewById(R.id.fit_daka_gou1);
        fit_daka_gou2=(ImageView)findViewById(R.id.fit_daka_gou2);
        fit_daka_gou3=(ImageView)findViewById(R.id.fit_daka_gou3);
        fit_daka_face1=(ImageView)findViewById(R.id.fit_daka_face1);
        fit_daka_face2=(ImageView)findViewById(R.id.fit_daka_face2);
        fit_daka_face3=(ImageView)findViewById(R.id.fit_daka_face3);
        fit_daka_queding=(ImageView)findViewById(R.id.fit_daka_queding);
        fit_daka_gou1.setVisibility(View.GONE);
        fit_daka_gou2.setVisibility(View.GONE);

        bofang_view=(View)findViewById(R.id.fit_bofang_view);
        playstat=(ImageView)findViewById(R.id.fit_play_stat);
        playstop=(ImageView)findViewById(R.id.fit_play_stop);
        playback=(ImageView)findViewById(R.id.fit_play_back);
        playgo=(ImageView)findViewById(R.id.fit_play_go);

        playstat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!mediaPlay.isPlaying()) {

                    playstop.setVisibility(View.VISIBLE);
                    playstat.setVisibility(View.GONE);
                    playstop.requestFocus();
                    mediaPlay.start();
//                    Behavior.onPlayContentStart(SimplePlayerActivity.this, mCateCode, mCateName, mContentCode, mTitle);
                } else {

                }

            }
        });

        playstop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(mediaPlay.isPlaying()) {
                    playstat.setVisibility(View.VISIBLE);
                    playstop.setVisibility(View.GONE);
                    playstat.requestFocus();
                    mediaPlay.pause();
//                    Behavior.onPlayContentStop(SimplePlayerActivity.this, mCateCode, mCateName, mContentCode, mTitle);
                }
            }
        });
        playback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(mediaPlay.isPlaying()) {
                    mediaPlay.seekTo(mediaPlay.getCurrentPosition() - 10000);
                }else{

                }
            }
        });
        playgo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(mediaPlay.isPlaying()) {
                    mediaPlay.seekTo(mediaPlay.getCurrentPosition() + 10000);
                }else{

                }
            }
        });
        if(FittimeActivity.WHICH_NUM==1){
            fit_daka_relayout.setBackgroundResource(R.drawable.fit_daka_majiaxian_bg);
        }else if(FittimeActivity.WHICH_NUM==2){
            fit_daka_relayout.setBackgroundResource(R.drawable.fit_daka_bailingnan_bg);
        }
        else if(FittimeActivity.WHICH_NUM==3){
            fit_daka_relayout.setBackgroundResource(R.drawable.fit_daka_wuyang_bg);
        }else if(FittimeActivity.WHICH_NUM==4){
            fit_daka_relayout.setBackgroundResource(R.drawable.fit_daka_nengliang_bg);
        }


        fit_daka_face1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fit_daka_gou1.setVisibility(View.VISIBLE);
                fit_daka_gou2.setVisibility(View.GONE);
                fit_daka_gou3.setVisibility(View.GONE);
            }
        });
        fit_daka_face2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fit_daka_gou1.setVisibility(View.GONE);
                fit_daka_gou2.setVisibility(View.VISIBLE);
                fit_daka_gou3.setVisibility(View.GONE);
            }
        });
        fit_daka_face3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fit_daka_gou1.setVisibility(View.GONE);
                fit_daka_gou2.setVisibility(View.GONE);
                fit_daka_gou3.setVisibility(View.VISIBLE);
            }
        });

        fit_daka_queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(fit_daka_gou1.getVisibility()==View.VISIBLE){
                    biaoqing_num=1;
                }else if(fit_daka_gou2.getVisibility()==View.VISIBLE){
                    biaoqing_num=2;
                }else{
                    biaoqing_num=3;
                }
             post_shangchuan();
                fit_daka_relayout.setVisibility(View.GONE);
                if(endtime==0) {
                    DataReport.ContentInformation(FittimeSimplePlayerActivity.this, "2200", FittimeErjiActivity.cate_code, FittimeErjiActivity.content_code, FittimeErjiActivity.vedio_name, mediaPlay.getCurrentPosition() + "");
                    int time_num=mediaPlay.getCurrentPosition()/1000;
                    int min=time_num/60;
                    final int col=time_num*335 / 3600;
                    DataReport.EventInformation(FittimeSimplePlayerActivity.this,"3300","000002","{\"emoji\":"+biaoqing_num+",\"duration\":"+mediaPlay.getCurrentPosition() +",\"cal\":"+col+"}");

                }else {

                    int time_num=time=mTime/1000;
                    int min=time_num/60;
                    final int col=time_num*335 / 3600;
                    DataReport.ContentInformation(FittimeSimplePlayerActivity.this, "2200", FittimeErjiActivity.cate_code, FittimeErjiActivity.content_code, FittimeErjiActivity.vedio_name, mTime + "");
                    DataReport.EventInformation(FittimeSimplePlayerActivity.this,"3300","000002","{\"emoji\":"+biaoqing_num+",\"duration\":"+mTime +",\"cal\":"+col+"}");
                }
                finish();
            }
        });

        fit_daka_name=(TextView)findViewById(R.id.fit_daka_name);
        fit_daka_time=(TextView)findViewById(R.id.fit_daka_time);
        fit_daka_col=(TextView)findViewById(R.id.fit_daka_col);
        fit_daka_touxiang=(CircleImageView)findViewById(R.id.fit_daka_touxiang);

        RequestQueue rq = Volley.newRequestQueue(this.getApplicationContext());
        JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wanba/photo_ajax_0907.jsp?userId="+ Util.getDeviceId(this), null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONArray arr=jsonObject.getJSONArray("userList");
                            JSONObject obj=arr.getJSONObject(0);
                            String iv_url=obj.getString("portraitUrl");
                            userurl=obj.getString("portraitUrl");
                            userid=obj.getString("userId");
                            fit_daka_name.setText(obj.getString("userName"));
                            username=obj.getString("userName");
                            RequestQueue mQueue = Volley.newRequestQueue(FittimeSimplePlayerActivity.this);
                            ImageRequest imageRequest = new ImageRequest(
                                    iv_url,
                                    new Response.Listener<Bitmap>() {
                                        @Override
                                        public void onResponse(Bitmap response) {
                                            fit_daka_touxiang.setImageBitmap(response);
                                        }
                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                @Override
                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                }
                            });
                            mQueue.add(imageRequest);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        }

        );
        rq.add(request);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_fittime_simple_player, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    private String jiami(String video_url){
        String url_team2=video_url;

        long time=System.currentTimeMillis();
        final String shijianchuo=Long.toHexString(time);
        final String key="w2nBa7VS1";

        String url_key=key+url_team2+shijianchuo;
        String key_1=string2MD5(url_key);
        String url_team="?auth_token="+key_1+"&auth_time="+shijianchuo;
        return url_team;
    }
    public static String string2MD5(String inStr){
        MessageDigest md5 = null;
        try{
            md5 = MessageDigest.getInstance("MD5");
        }catch (Exception e){
            System.out.println(e.toString());
            e.printStackTrace();
            return "";
        }
        char[] charArray = inStr.toCharArray();
        byte[] byteArray = new byte[charArray.length];

        for (int i = 0; i < charArray.length; i++)
            byteArray[i] = (byte) charArray[i];
        byte[] md5Bytes = md5.digest(byteArray);
        StringBuffer hexValue = new StringBuffer();
        for (int i = 0; i < md5Bytes.length; i++){
            int val = ((int) md5Bytes[i]) & 0xff;
            if (val < 16)
                hexValue.append("0");
            hexValue.append(Integer.toHexString(val));
        }
        return hexValue.toString().toLowerCase();

    }
    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        mediaPlay=new MediaPlayer();
        mediaPlay.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mediaPlay.setDisplay(surfaceholder);
        mediaPlay.setOnPreparedListener(this);
        mediaPlay.setOnCompletionListener(this);
        try {
            if(FittimeErjiActivity.vedio!=null){
                String url=FittimeErjiActivity.vedio.replace("cdn","www");
                mediaPlay.setDataSource(url);
            }else {
                mediaPlay.setDataSource("http://www.wanbatv.com/dogtv/DOGE7021_H264_16-9_1920x1080_2000000bps.TS");
            }
                mediaPlay.prepareAsync();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

    }


    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {

    }


    @Override
    public void onCompletion(MediaPlayer mp) {
        mp.release();
        endtime=mTime;
        DataReport.EventInformation(FittimeSimplePlayerActivity.this,"3300","000003","{\"contentcode\":"+FittimeErjiActivity.content_code+",\"categorycode\":"+FittimeErjiActivity.cate_code+",\"duration\":"+mTime+"}");

        fit_daka_relayout.setVisibility(View.VISIBLE);
        fit_daka_face3.requestFocus();
        time=mediaPlay.getDuration();
        int time_num=time/1000;
        int min=time_num/60;
        int col=time_num*335 / 3600;
//        fit_daka_name.setText("张国钰木有小JJ");
        fit_daka_time.setText(min+" min");
        fit_daka_col.setText(col+" col");


    }


    @Override
    public void onPrepared(MediaPlayer mp) {
        mp.start();
        DataReport.ContentInformation(FittimeSimplePlayerActivity.this,"1200", FittimeErjiActivity.cate_code, FittimeErjiActivity.content_code, FittimeErjiActivity.vedio_name,  "0");

        playprogressbar.setMax(mediaPlay.getDuration());
        mTime=mediaPlay.getDuration();
        mHandler.sendEmptyMessage(MSG_PLAY_PROGRESS);
        time=mediaPlay.getDuration();
        int b=time/1000;
        int s=b%60;
        int m=b/60;
        String ss=null;
        if(s<10){
            ss="0"+s;
        }else{
            ss=s+"";
        }
        fit_erji_demo_tv2.setText(m+":"+ss);
        int time_num=time/1000;
        int min=time_num/60;
        int col=time_num*335/3600;
//        fit_daka_name.setText("张国钰木有小JJ");
        fit_daka_time.setText(min+" min");
        fit_daka_col.setText(col+" col");
        post_shangchuan2();
    }

    @Override
    protected void onStop() {
        super.onStop();
        mediaPlay.stop();
        mediaPlay.release();
        DataReport.PageRetreat(FittimeSimplePlayerActivity.this, "1100", "300006");
    }

    @Override
    protected void onStart() {
        super.onStart();
        DataReport.PageRetreat(FittimeSimplePlayerActivity.this, "1100", "300005");
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if((keyCode == KeyEvent.KEYCODE_DPAD_LEFT)) {
            if (mStateFastSeek == STATE_FAST_SEEK_START) {
                mStateFastSeek = STATE_FAST_SEEK_IDLE;
                mLastEvent = null;
                mDownEvent =null;
            }
        }
        return super.onKeyUp(keyCode, event);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_BACK){
            if(fit_daka_relayout.getVisibility()==View.GONE){
                fit_daka_relayout.setVisibility(View.VISIBLE);
                fit_daka_face3.requestFocus();
                playstat.setFocusable(false);
                playstop.setFocusable(false);
                playback.setFocusable(false);
                playgo.setFocusable(false);
                int time_num=bofang_time/1000;
                int min=time_num/60;
                int col=time_num*335/3600;
//        fit_daka_name.setText("张国钰木有小JJ");
                fit_daka_time.setText(min+" min");
                fit_daka_col.setText(col+" col");
            }else{
                fit_daka_relayout.setVisibility(View.GONE);
                playstat.setFocusable(true);
                playstop.setFocusable(true);
                playback.setFocusable(true);
                playgo.setFocusable(true);
                if(playstop.getVisibility()==View.GONE){
                    playstat.requestFocus();
                }else{
                    playstop.requestFocus();
                }
            }
            return true;
        }else if((keyCode == KeyEvent.KEYCODE_DPAD_LEFT)){
            if((playback.getVisibility()==View.INVISIBLE)){

                return true;
            }else {
                if (mStateFastSeek == STATE_FAST_SEEK_IDLE) {

                    mStateFastSeek = STATE_FAST_SEEK_PREPARED;
                    mDownEvent = event;
                } else if (mStateFastSeek == STATE_FAST_SEEK_PREPARED) {

                    final long deltaEventTime = event.getEventTime() - mDownEvent.getDownTime();
                    if (deltaEventTime > 300) {
                        mStateFastSeek = STATE_FAST_SEEK_START;
                        mLastEvent = event;
                        Log.d("KeyEvent", "@@@ onKeyDown at " + event.getEventTime());
                        if(mediaPlay.isPlaying()) {
                            mediaPlay.seekTo(mediaPlay.getCurrentPosition() - 2000);
                        }else{
                            KUAIJIN_TIME-=2000;
                        }
                    }
                } else if (mStateFastSeek == STATE_FAST_SEEK_START) {
                    final long deltaEventTime = event.getEventTime() - mLastEvent.getEventTime();
                    if (deltaEventTime > 100) {
                        mLastEvent = event;
                        Log.d("KeyEvent", "@@@ onKeyDown at " + event.getEventTime());
                        if(mediaPlay.isPlaying()) {
                            mediaPlay.seekTo(mediaPlay.getCurrentPosition() - 2000);
                        }else{
                            KUAIJIN_TIME-=2000;
                        }

                    }
                }

                return super.onKeyDown(keyCode, event);
            }
        }
        else if((keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)){
            Log.d("KeyEvent", "@@@ onKeyDown at 22");
            if((playback.getVisibility()==View.INVISIBLE)){

                return true;
            }else {
                if (mStateFastSeek == STATE_FAST_SEEK_IDLE) {
                    mStateFastSeek = STATE_FAST_SEEK_PREPARED;
                    mDownEvent = event;
                    Log.d("KeyEvent", "@@@ onKeyDown at 22 9");
                } else if (mStateFastSeek == STATE_FAST_SEEK_PREPARED) {
                    Log.d("KeyEvent", "@@@ onKeyDown at 22 10");
                    final long deltaEventTime = event.getEventTime() - mDownEvent.getDownTime();
                    Log.d("KeyEvent", "@@@ onKeyDown at"+deltaEventTime);
                    if (deltaEventTime > 300) {
                        mStateFastSeek = STATE_FAST_SEEK_START;
                        mLastEvent = event;
                        Log.d("KeyEvent", "@@@ onKeyDown at " + event.getEventTime());
                        if(mediaPlay.isPlaying()) {
                            mediaPlay.seekTo(mediaPlay.getCurrentPosition() + 2000);
                            Log.d("KeyEvent", "@@@ onKeyDown at 22 11");
                        }else{
                            KUAIJIN_TIME+=2000;
                        }

                    }
                } else if (mStateFastSeek == STATE_FAST_SEEK_START) {
                    final long deltaEventTime = event.getEventTime() - mLastEvent.getEventTime();
                    if (deltaEventTime > 100) {
                        mLastEvent = event;
                        Log.d("KeyEvent", "@@@ onKeyDown at " + event.getEventTime());
                        if(mediaPlay.isPlaying()) {
                            mediaPlay.seekTo(mediaPlay.getCurrentPosition() + 2000);
                        }else{
                            KUAIJIN_TIME+=2000;
                        }

                    }
                }
                return super.onKeyDown(keyCode, event);
            }
        }

        else {
            return super.onKeyDown(keyCode, event);
        }
    }

    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        return false;
    }
    private void post_shangchuan(){
        RequestQueue requestQueue = Volley.newRequestQueue(FittimeSimplePlayerActivity.this);
        String url="http://61.191.46.214:8087/fittime/checkin";
        StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.POST,url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                //在这里设置需要post的参数
                Map<String, String> map = new HashMap<String, String>();
                map.put("contentcode", FittimeErjiActivity.content_code);
                map.put("category", FittimeErjiActivity.cate_code);
                map.put("day",FittimeErjiActivity.day);
                map.put("emoji",biaoqing_num+"");
                map.put("title",FittimeErjiActivity.vedio_name);
                map.put("duration",bofang_time/1000+"");
                map.put("deviceid",Util.getDeviceId(FittimeSimplePlayerActivity.this));
                map.put("region","23");
                map.put("wxnickname",username);
                map.put("wxuserid",userid);
                map.put("wxportrait",userurl);
                return map;
            }
        };
        requestQueue.add(stringRequest);
    }
    private void post_shangchuan2(){
        RequestQueue requestQueue = Volley.newRequestQueue(FittimeSimplePlayerActivity.this);
        String url="http://61.191.46.214:8087/fittime/currentplay";
        StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.POST,url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                //在这里设置需要post的参数
                Map<String, String> map = new HashMap<String, String>();
                map.put("deviceid",Util.getDeviceId(FittimeSimplePlayerActivity.this));
                map.put("contentcode", FittimeErjiActivity.content_code);
                map.put("category", FittimeErjiActivity.cate_code);
                map.put("region","23");
                return map;
            }
        };
        requestQueue.add(stringRequest);
    }
}
